#ifndef LYRICVIEW_H
#define LYRICVIEW_H

#include <QWidget>
#include <QListWidget>
#include <QVBoxLayout>
#include <QList>
#include <QLabel>
#include <QDialog>
#include <QMouseEvent>

class LyricItem
{
public:
    int index;
    QString time;//时间
    QString content;//歌词

    LyricItem(int index,QString time,QString content);
    ~LyricItem();
};

class DesktopLyricDialog : public QDialog
{
public:
    QPoint dragStartPosition;
    QLabel *desktopLyricLabel;
    QVBoxLayout *desktopLyricLayout;
    void updateLyric(QString lyric);
    DesktopLyricDialog(QWidget *parent = 0);
    ~DesktopLyricDialog();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

};

class LyricView : public QWidget
{
    Q_OBJECT
public:
    bool desktopLyricShow = false;
    QListWidget *listWidget;
    QVBoxLayout *layout;
    QList<LyricItem*> *lyricItemList;//歌词列表
    DesktopLyricDialog *desktopLyricDialog;//桌面歌词
    int currentIndex;//当前歌词索引
    explicit LyricView(QWidget *parent = 0);
    void setLyric(QString lyrics);//设置歌词
    void scrollToItemByTime(QString time);//滚动到指定时间位置歌词
    qint64 timeStringToMillis(const QString& timeString);//将时间格式的QString转换为总毫秒数
    void desktopLyric();

    ~LyricView();


signals:

public slots:
    void onDesktopLyricDialogClosed();
    void closeLyricDialog();
};

#endif // LYRICVIEW_H
